package example;

import example.service.CommentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除评论的Servlet
 *
 * @author 张心怡
 * @date 2024/12/16
 */
@WebServlet("/delCommentServlet")
public class DelCommentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("comment_id"));
        int bookId = Integer.parseInt(request.getParameter("book_id"));
        CommentService.deleteComment(id);
        // 可以根据需要进行页面跳转或者返回响应信息
        response.sendRedirect("commentServlet?book_id=" + bookId);
    }
}